package com.xmy.study.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.xmy.study.entity.WillingnessSurvey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface WillingnessSurveyMapper {
    @Select({"<script>",
            "SELECT count(id) FROM xmy_erp_db.willingness_survey ${ew.customSqlSegment}",
            "</script>"})
    public abstract long getCount(@Param(Constants.WRAPPER) Wrapper<WillingnessSurvey> wrapper);

    @Select({"<script>",
            "INSERT INTO `xmy_erp_db`.`willingness_survey` (`student_id`, `type`, `state`, `created_at`, `updated_at`, `year_part`, `quarter_num`, `is_fill`, `add_time`, `school_id`, `grade_id`, `teacher_id`, `teacher_name`, `subjects_id`, `class_type_id`, `year_class_id`, `student_name`) ",
            " VALUES (#{ew.studentId}, #{ew.type}, #{ew.state}, NOW(), NOW(), #{ew.yearPart}, #{ew.quarterNum}, 1, ${ew.addTime}, #{ew.schoolId}, #{ew.gradeId}, #{ew.teacherId}, #{ew.teacherName}, #{ew.subjectsId}, #{ew.classTypeId}, #{ew.yearClassId}, #{ew.studentName}) ",
            "</script>"})
    public abstract void goToSave(@Param(Constants.WRAPPER) WillingnessSurvey willingnessSurvey);
}
